package homework;


import java.util.Random;

public class SortRandom {
    public static void main(String[] args) {
        Random random=new Random();
        int [] number=new int[10];
        for (int i=0;i<10;i++)
        {
            number[i]=random.nextInt(101);
        }

        System.out.println("生成的的随机数为：");
        for (int i:number
             ) {
            System.out.print(i+" ");
        }

        System.out.println("");
        //排序算法（选择排序），升序
        for(int i=0;i<10;i++)
        {
            for (int j=i+1;j<10;j++)
            {
                if(number[i]>number[j]){
                    int n=number[i];
                    number[i]=number[j];
                    number[j]=n;

                }


            }
        }

        System.out.println("随机数（升序）排序后为：");
        for (int i:number
             ) {
            System.out.print(i+" ");
        }
    }
}
